package code.assets
{
	import code.interfaces.ISubMenu;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	
	import mx.core.BitmapAsset;
	import mx.core.UIComponent;
	
	public class CloseBtn extends UIComponent implements ISubMenu
	{
		private var _id:String;
		
		[Embed("assets/close_icon.png")]
		public static var Img:Class;
		
		public function CloseBtn()
		{
			super();
			
			addEventListener(MouseEvent.ROLL_OVER, onRollover);
			addEventListener(MouseEvent.ROLL_OUT, onRollout);
			addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
			
			create();
		}
		
		protected function create():void
		{
			var bm:BitmapAsset = new Img();
			var matrix:Matrix = new Matrix();
			matrix.a = 24 / bm.width;
			matrix.d = 24 / bm.height;
			this.graphics.beginBitmapFill(bm.bitmapData, matrix);
			this.graphics.drawRect(0, 0, 24, 24);
			this.graphics.endFill();
			/*this.graphics.beginFill(0xFF0000);
			this.graphics.drawCircle(50,50,50);
			this.graphics.endFill();*/
		}
		
		protected function onRollover(evt:MouseEvent):void
		{
			Mouse.cursor = MouseCursor.BUTTON;
		}
		
		protected function onRollout(evt:MouseEvent):void
		{
			Mouse.cursor = MouseCursor.ARROW;
		}
		
		protected function onRemoved(evt:Event):void
		{
			removeEventListener(MouseEvent.ROLL_OVER, onRollover);
			removeEventListener(MouseEvent.ROLL_OUT, onRollout);
			removeEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
		}
		public function set linkID(nm:String):void
		{
			_id = nm;
		}
		
		public function get linkID():String
		{
			return _id;
		}
	}
}